﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Randata.Helpers;

namespace Randata.DataResolvers.Implementation
{
    internal class EnumDataResolver<T> : DataResolver<T>
    {
        internal override T Resolve()
        {
            Type type = typeof(T);

            String[] names = Enum.GetNames(type);
            String selectedName = names.AnyOne();
            Object obj = Enum.Parse(type, selectedName, true);
            return (T)obj;

            //MemberInfo[] members = type.GetMembers(BindingFlags.Public | BindingFlags.Static);
            //FieldInfo selectedMember = (FieldInfo)members.AnyOne();
            //return (T)selectedMember.GetValue();
        }
    }
}
